﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IPC.Communication.Core;

namespace IPC.Communication.MQTT
{
    public class MqttConnectionOptions
    {
        private string ipAddress = "127.0.0.1";

        public string IpAddress
        {
            get
            {
                return ipAddress;
            }
            set
            {
                ipAddress = HslHelper.GetIpAddressFromInput(value);
            }
        }

        public int Port
        {
            get;
            set;
        }

        public string ClientId
        {
            get;
            set;
        }

        public int ConnectTimeout
        {
            get;
            set;
        }

        public MqttCredential Credentials
        {
            get;
            set;
        }

        public TimeSpan KeepAlivePeriod
        {
            get;
            set;
        }

        public TimeSpan KeepAliveSendInterval
        {
            get;
            set;
        }

        public bool CleanSession
        {
            get;
            set;
        }

        public MqttConnectionOptions()
        {
            ClientId = string.Empty;
            IpAddress = "127.0.0.1";
            Port = 1883;
            KeepAlivePeriod = TimeSpan.FromSeconds(100.0);
            KeepAliveSendInterval = TimeSpan.FromSeconds(30.0);
            CleanSession = true;
            ConnectTimeout = 5000;
        }
    }
}
